import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;

public class MainGame extends JFrame {

	private JPanel contentPane;
	static MainGame frame;
	static PlayGame play;
	static HuongDan hd;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					frame = new MainGame();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public MainGame() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 700, 500);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JButton btnNewButton = new JButton("CHƠI");
		//Chuyển vào frame ChơiGame
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				play = new PlayGame();
				play.setVisible(true);
				play.setResizable(false);
				frame.setVisible(false);
			}
		});
		btnNewButton.setBounds(166, 303, 125, 74);
		contentPane.add(btnNewButton);
		
		JButton button = new JButton("THOÁT");
		
		//Sự kiện cho nút thoát
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				System.exit(0);
			}
		});
		button.setBounds(373, 303, 125, 74);
		contentPane.add(button);
		
		JButton btnhd = new JButton("Hướng Dẫn");
		//chuyển vào giao diện hướng dẫn
		btnhd.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				hd = new HuongDan();
				hd.setVisible(true);
				hd.setResizable(false);
				frame.setVisible(false);
			}
		});
		btnhd.setBounds(270, 385, 125, 74);
		contentPane.add(btnhd);
		
		JLabel lblNewLabel = new JLabel("HỨNG TRỨNG");
		lblNewLabel.setForeground(Color.RED);
		lblNewLabel.setFont(new Font("Times New Roman", Font.BOLD, 26));
		lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
		lblNewLabel.setBounds(78, 27, 498, 46);
		contentPane.add(lblNewLabel);
		
		//các image giao diện
		JLabel label = new JLabel();
		try {
			BufferedImage trung=ImageIO.read(new File("src\\Images\\egg.png"));
			ImageIcon ictrung=new ImageIcon(trung.getScaledInstance(120,150, trung.SCALE_SMOOTH));
			label.setIcon(ictrung);
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
		label.setBounds(104, 114, 157, 133);
		label.setSize(120,150);
		contentPane.add(label);

		
		JLabel label_1 = new JLabel();
		try {
			BufferedImage ro=ImageIO.read(new File("src\\Images\\Ro.png"));
			ImageIcon icro=new ImageIcon(ro.getScaledInstance(120,150, ro.SCALE_SMOOTH));
			label_1.setIcon(icro);
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		label_1.setSize(120,150);
		label_1.setBounds(287, 114, 120, 150);
		contentPane.add(label_1);
		
		JLabel label_2 = new JLabel();
		try {
			BufferedImage shit=ImageIO.read(new File("src\\Images\\shit.png"));
			ImageIcon icshit=new ImageIcon(shit.getScaledInstance(120,150, shit.SCALE_SMOOTH));
			label_2.setIcon(icshit);
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}		
		label_2.setSize(120,150);
		label_2.setBounds(456, 114, 120, 150);
		contentPane.add(label_2);
		
		
	}
}
